import { Controller, Body, UseGuards, Post, Req } from '@nestjs/common'
import { ApiBearerAuth, ApiConsumes, ApiOperation, ApiTags, } from '@nestjs/swagger'
import { MenuDetailService } from './menuDetail.service'
import { Request } from 'express'
import { MenuDetailDto } from './dto/menu-detail.dto'
import { RateLimit } from '../common/rateLimit/rate-limit.decorator'

@ApiTags('menu')
// @ApiBearerAuth('JWT')
@Controller('menu')
// @UseGuards(JwtAuthGuard)
export class MenuDetailController {
  constructor(private readonly menuDetailService: MenuDetailService) { }

  // 菜品详情
  @ApiOperation({ summary: '菜品详情' })
  @ApiConsumes('application/x-www-form-urlencoded')
  @RateLimit(30, 60 * 1000)
  @Post('/detail/:id')
  async getDetail(@Body() data: MenuDetailDto, @Req() req: Request) {
    return this.menuDetailService.getDetail(req.user?.id as number, data)
  }
}
